﻿@{
    ViewBag.Title = "ReportDefaultIndex";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        if ("block" == $("#swichId").val()) {
            $("#schAndEduArea").css('display', 'block');
            $("#stuArea").css('display', 'none');
            gridList();
            $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'left', 'vertical-align': 'middle', 'width': '25' });
        }
        else {
            $("#stuArea").css('display', 'block');
            $("#schAndEduArea").css('display', 'none');
        }
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/Apply/GetReportDataJson",
            height: $(window).height() - 120,
            colModel: [
                {
                    label: '学校', name: 'SchoolId', width: 150, align: 'left',
                    formatter: function (cellvalue) {
                        return top.clients.schoolItems[cellvalue] == undefined ? "" : top.clients.schoolItems[cellvalue].schoolName
                    }
                },
                {
                    label: '年级', name: 'ClassValue', width: 150, align: 'right',
                    formatter: function (cellvalue) {
                        return top.clients.dataItems["Class"][cellvalue] == undefined ? "" : top.clients.dataItems["Class"][cellvalue]
                    }
                },
                { label: "年级学位总数", name: "ClassFreeTotalAmount", width: 250, align: 'center' },
                { label: '年级学位剩余数', name: 'ClassFreeAmount', width: 250, align: 'center' },
                {
                    label: "租房可见", name: "isRent", width: 100, align: "left",
                    formatter: function (cellvalue) {
                        return cellvalue == 1 ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>";
                    }
                },
                { label: '', name: '', width: 50, align: 'center' },
            ],
            sortname: 'SchoolId asc',
            viewrecords: true,
            footerrow: true,
            loadComplete: function (xhr) {
                var rows = $("#gridList").jqGrid("getRowData");
                var total_ClassFreeTotalAmount = 0;
                var total_ClassFreeAmount = 0;
                for (var i = 0, l = xhr.rows.length; i < l; i++) {
                    total_ClassFreeTotalAmount += parseInt(xhr.rows[i].ClassFreeTotalAmount);
                    total_ClassFreeAmount += parseInt(xhr.rows[i].ClassFreeAmount);
                }
                $("#gridList").jqGrid("footerData", "set", {
                    rn: "<font color='red'>合计</font>",
                    ClassFreeTotalAmount: "<font color='red'> " + total_ClassFreeTotalAmount + "</font>",
                    ClassFreeAmount: "<font color='red'> " + total_ClassFreeAmount + "</font>",
                });
            }
        });
    }
</script>
<div><input type="hidden" name="swichId" id="swichId" value="@ViewBag.switchDiv" /></div>
<div id="schAndEduArea" style="display:none">
    <div class="topPanel">
        <div class="toolbar">
            <div class="btn-group">
                <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
            </div>
        </div>
    </div>
    <div class="gridPanel">
        <table id="gridList"></table>
    </div>
    <div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
</div>
<div id="stuArea" style="width:300px;float:left;padding-right:50px;display:none">
    <h3>系统公告</h3>
    <div class="content-area">
        系统正在维护中...
    </div>
</div>
